//
//  CYHomeSafeCell.m
//  cyjf
//
//  Created by tauCross on 2017/7/5.
//  Copyright © 2017年 Auto Financing. All rights reserved.
//

#import "CYHomeSafeCell.h"



@implementation CYHomeSafeCellObject

@end



@interface CYHomeSafeCell ()

@property(nonatomic, strong)UIImageView *safeImageView;

@end


@implementation CYHomeSafeCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self)
    {
        self.contentView.backgroundColor = [UIColor whiteColor];
        
        self.safeImageView = [[UIImageView alloc] init];
        self.safeImageView.image = CYImage(@"home_safe");
        self.safeImageView.layer.masksToBounds = YES;
        self.safeImageView.layer.cornerRadius = 5;
        self.safeImageView.contentMode = UIViewContentModeScaleAspectFill;
        [self.contentView addSubview:self.safeImageView];
    }
    return self;
}

+ (CGFloat)heightForObject:(id)object atIndexPath:(NSIndexPath *)indexPath tableView:(UITableView *)tableView
{
    return 90 * (tableView.width - 20) / 355 + 20;
}

- (BOOL)shouldUpdateCellWithObject:(id)object
{
    [self setNeedsLayout];
    return YES;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    self.safeImageView.width = self.contentView.width - 20;
    self.safeImageView.height = self.contentView.height - 20;
    self.safeImageView.centerX = self.contentView.width / 2;
    self.safeImageView.centerY = self.contentView.height / 2;
}

@end
